import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询店员列表
export function listUser(data) {
  return request({
    url: '/employee/user/employeeUserList',
    method: 'post',
    data: data
  })
}

// 查询店员详细
export function getUser(userId) {
  return request({
    url: '/employee/user/' + parseStrEmpty(userId),
    method: 'get'
  })
}

// 新增店员
export function addUser(data) {
  return request({
    url: '/employee/user/employeeUserAdd',
    method: 'post',
    data: data
  })
}

// 修改店员
export function updateUser(data) {
  return request({
    url: '/employee/user/employeeUserUpdate',
    method: 'post',
    data: data
  })
}

// 删除店员
export function delUser(userId) {
  return request({
    url: '/employee/user/' + userId,
    method: 'delete'
  })
}

// 店员密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/employee/user/employeeUserResetPwd',
    method: 'put',
    data: data
  })
}

// 店员状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/employee/user/employeeUserChangeStatus',
    method: 'put',
    data: data
  })
}

// 查询店员个人信息
export function getUserProfile() {
  return request({
    url: '/employee/user/profile',
    method: 'get'
  })
}

// 修改店员个人信息
export function updateUserProfile(data) {
  return request({
    url: '/employee/user/profile',
    method: 'put',
    data: data
  })
}

// 店员密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/employee/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 店员头像上传
export function uploadAvatar(data) {
  return request({
    url: '/employee/user/profile/avatar',
    method: 'post',
    data: data
  })
}

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: '/employee/user/employeeUserDeptTree',
    method: 'get'
  })
}
